#include <bits/stdc++.h>
using namespace std;
#define int long long

int myabs(int x) {
	if (x > 0) return x;
	return -x;
}
signed main() {
	freopen("sub.in", "r", stdin); freopen("sub.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	int tc; cin >> tc;
	while (tc--) {
		int a, b;
		cin >> a >> b;
		if (a < b) swap(a, b);
		if (a >= 0 && b <= 0) {
			cout << min({myabs(b), myabs(a), myabs(a + b)}) << "\n";
		} else {
			cout << 0 << "\n";
		}
	}
	return 0;
}
